<?php
/**
 * Zend Framework Contribution
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Mwb
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    1.0 IndexColumn.php 3 mai 2012 Sergio DE VASCONCELOS
 */

require_once('Zend/Mwb/Dom/Abstract.php');

/**
 * MySQL Workbench document
 *
 * @category   Zend
 * @package    Zend_Mwb
 */
class Zend_Mwb_Dom_IndexColumn extends Zend_Mwb_Dom_Abstract
{
	protected $referencedColumn;
	
	public function getReferencedColumn() {
		if (is_null($this->referencedColumn)) {
			$this->referencedColumn = $this->loadReferencedColumn();
		}
		return $this->referencedColumn;
	}
	
	public function parse() {
		$this->xpath = new DOMXPath($this->node->ownerDocument);
		
		//$this->referencedColumn     = $this->loadReferencedColumn();
	}
	/**
	 * @param DOMElement $dom
	 * @return Zend_Mwb_Dom_Column
	 */
	protected function loadReferencedColumn() {
    	$element = $this->xpath->query("link[@key='referencedColumn']", $this->node)->item(0);
    	if (isset($element)) {
	    	$elementId = $element->textContent;
	    	$element = $this->xpath->query("//*[@id='".$elementId."']")->item(0);
	    	return $element->getDom();
        	
        } else {
        	require_once 'Zend/Mwb/Exception.php';
        	throw new Zend_Mwb_Exception('Dom_Exception_Null($this->node)');
        }
	}
	
	public function create() {
		
	}
}
